
window.onload = function () {
    var music = document.getElementById("music");
    var audio = document.getElementsByTagName("audio")[0];
    // music.onclick = function () {//会延迟300ms
    //     if (audio.paused){
    //         audio.play();
    //         this.style.animationPlayState = "running";
    //         // this.setAttribute("class","play");
    //     }else {
    //         audio.pause();
    //         this.style.animationPlayState = "paused";
    //         // this.setAttribute("class","");
    //     }
    // };
    music.addEventListener("touchstart",function (event) {
        if (audio.paused){
            audio.play();
            this.style.animationPlayState = "running";
            // this.setAttribute("class","play");
        }else {
            audio.pause();
            this.style.animationPlayState = "paused";
            // this.setAttribute("class","");
        }
    });
    //音乐播放完毕
    audio.addEventListener("ended",function () {
        music.style.animationPlayState = "paused";
    });
};